package nucleo;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;

/**
 *
 * @author OsomGames
 * @date 18-07-2011
 */
public class Sprite {
    
    /**
     * Clase usada para cargar sprites
     * @param ruta
     * @param filas
     * @param columnas
     * @param ancho
     * @param alto
     * @return BufferedImage[] array de sprites
     * @throws IOException 
     */
    public static BufferedImage[] cargaSprites(String ruta, Integer filas,
        Integer columnas, Integer ancho, Integer alto) throws IOException {
        BufferedImage bigImg = ImageIO.read(new File(ruta));
        BufferedImage[] sprites = new BufferedImage[filas * columnas];

        for (int i = 0; i < filas; i++) {
            for (int j = 0; j < columnas; j++) {
                sprites[(i * columnas) + j] = bigImg.getSubimage(j * ancho, i
                        * alto, ancho, alto);
            }
        }
        return sprites;
    }
}
